package cn.dzhang.spring.web.model;

import java.util.Iterator;
import java.util.List;

import javax.xml.bind.annotation.XmlTransient;

public abstract class ModelsWrap<M> implements Iterator<M> {

	protected List<M> list;
	private Iterator<M> iterator;

	public ModelsWrap() {
	}

	public ModelsWrap(List<M> list) {
		setList(list);
	}

	public void setList(List<M> list) {
		this.list = list;
		this.iterator = list.iterator();
	}

	@XmlTransient
	public abstract List<M> getList();

	@Override
	public boolean hasNext() {
		return iterator.hasNext();
	}

	@Override
	public M next() {
		return iterator.next();
	}

	@Override
	public void remove() {
		iterator.remove();
	}

}
